<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <title>后台管理</title>
    <link href="style/login.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../js/boot.js"></script>
</head>

<body>
    <div class="login_box">
        <div class="login_l_img"><img src="style/images/login-img.png" /></div>
        <div class="login">
            <div class="login_logo"><a href="#"><img src="style/images/login_logo.png" /></a></div>
            <div class="login_name">
                <p>后台管理系统</p>
            </div>
            <form method="post">
                <input id="username" name="username" type="text" value="用户名" onfocus="this.value=''" onblur="if(this.value==''){this.value='用户名'}">
                <input id="password" name="password" type="password" onfocus="this.value=''" onblur="if(this.value==''){this.value='密码'}"/>
                <input value="登录" style="width:100%;" type="button" onclick="javascript:login();">
            </form>
        </div>
        <div class="copyright">fengjian 版权所有©2018-2028 技术支持电话：13814608011</div>
    </div>
</body>

<script type="text/javascript">

    // TODO 用这个方式查找图片路径，再动态处理或更换
    // alert($("[src$='.png']"));

    function login() {
        var username = $("#username").val();
        var password = $("#password").val();
        if (username == '') {
            alert("用户名不能为空！");
            return;
        }
        if (password == '') {
            alert("密码不能为空！");
            return;
        }
        params = {
            "loginName": username,
            "loginPassword": password
        };
        http.post("/user/any/login.do", params, function (data) {
            debugger
            if (data.success) {
                localStorage.setItem('_token', data.dataMap._token);
                var user = data.data;
                user.token = data.dataMap.token;
                localStorage.setItem('user', mini.encode(user));
                window.location.href = "./dashboard.html";
            } else {
                alert(data.message);
            }
        });
    }
</script>

</html>